apiVersion: v1
kind: Service
metadata:
  name: kafka
  namespace: spark-cluster
  labels:
    app: kafka
    component: kafka-broker
spec:
  type: NodePort
  ports:
  - port: 9092
    name: kafka-port
    targetPort: 9092 
    protocol: TCP
    nodePort: 30092
  - name: kafka-ssh
    port: 22
    targetPort: 22
  selector:
    app: kafka
    component: kafka-broker

---
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    app: kafka
    component: kafka-broker
  name: kafka-broker
  namespace: spark-cluster
spec:
  replicas: 7
  template:
    metadata:
      labels:
        app: kafka
        component: kafka-broker
    spec:
      containers:
      - name: kafka
        image: index.tenxcloud.com/zhangshun/kafka-kube:0.10.0.1
        ports:
        - containerPort: 9092
        - containerPort: 22
        volumeMounts:
        - mountPath: /opt/kafka_2.11-0.10.0.1/logs
          name: rta-kafka
        resources:
          requests:
            cpu: 100m
        env:
          - name: ENABLE_AUTO_EXTEND
            value: "true"
          - name: KAFKA_RESERVED_BROKER_MAX_ID
            value: "999999999"
          - name: KAFKA_AUTO_CREATE_TOPICS_ENABLE
            value: "true"
          - name: KAFKA_PORT
            value: "9092"
          - name: KAFKA_ADVERTISED_PORT
            value: "9092"
          - name: KAFKA_DELETE_TOPIC_ENABLE
            value: "true"
          - name: KAFKA_ADVERTISED_HOST_NAME
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          - name: KAFKA_ZOOKEEPER_CONNECT
            value: kafka-zoo-svc:2181
          #- name: KAFKA_CREATE_TOPICS
          #  value: demo-topic:16:1
      volumes:
      - name: rta-kafka
        glusterfs:
            endpoints: glusterfs-cluster
            path: {{ gluster_rta_kafka_volname }}
            readOnly: false
